package com.mrjy.common.handler;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;

import com.mrjy.activity.dto.TeacherDTO;
/**
 * map结果集映射处理器
 * @author Josh
 *
 */
public class MapResultHandler implements ResultHandler{
	
	private final Map<Integer,List<TeacherDTO>> mappedResults = new HashMap<Integer,List<TeacherDTO>>();
 
	@Override
	public void handleResult(ResultContext context) {
		TeacherDTO teacherDTO = (TeacherDTO) context.getResultObject(); 
		if (!mappedResults.containsKey(teacherDTO.getActivityId())) {
            mappedResults.put(teacherDTO.getActivityId(), new ArrayList<TeacherDTO>());
        }
        mappedResults.get(teacherDTO.getActivityId()).add(teacherDTO);
	}
	public  Map<Integer,List<TeacherDTO>> getMappedResults() {  
        return mappedResults;  
    } 
}
